package main

import (
	"net/http"

	"github.com/gin-gonic/gin"
)

/*
  get post  传值
*/

func main() {
	r := gin.Default()

	r.GET("/get", func(c *gin.Context) {
		username := c.Query("username")
		age := c.Query("age")
		page := c.DefaultQuery("page", "1")
		c.JSON(http.StatusOK, gin.H{
			"username": username,
			"age":      age,
			"page":     page,
		})
	})

	r.POST("/post", func(c *gin.Context) {
		username := c.PostForm("username")
		password := c.DefaultPostForm("password", "0000")
		c.JSON(http.StatusOK, gin.H{
			"username": username,
			"password": password,
		})
	})

	r.Run(":9000")

}
